package com.deyuanyun.pic.settings.task;

import com.deyuanyun.pic.settings.service.msgtemplate.AbstractPushMsgTemplate;
import com.deyuanyun.pic.settings.service.msgtemplate.RiskSystemPushMsg;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean;

/**
 *  风险评价 - 系统风险等任务调度
 *  @author axiao(xj08.dream@gmail.com)
 *  @date 2016-07-20
 *  @version 1.0
 *  Histroy: [修改人][时间][描述]
 */
public class RiskSystemTask extends MethodInvokingJobDetailFactoryBean.StatefulMethodInvokingJob {

    private static final Logger LOGGER = LoggerFactory.getLogger(RiskSystemTask.class);

    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        try {
            if(LOGGER.isInfoEnabled()) {
                JobKey jobKey = context.getTrigger().getJobKey();
                LOGGER.info("得到需要执行的任务名为：" + jobKey.getName());
                LOGGER.info("得到需要执行的任务组名为："  + jobKey.getGroup());
                LOGGER.info("***系统风险等任务调度开始执行***");
            }
            AbstractPushMsgTemplate abstractPushMsgTemplate  = new RiskSystemPushMsg(); //风险评价页面-----风险等级相关消息推送模板
            abstractPushMsgTemplate.pushMsg();
            if(LOGGER.isInfoEnabled())
                LOGGER.info("***系统风险等任务调度执行结束***");
        } catch (Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
    }
}
